I wish to be able to create a DXL script to restore archived files.
/*
Rev 1.000 - This script will perform an archive restore on modules residing in the DOORS Development server area.
Input - N/A
Output - N/A
*/
string strModuleName
string strNewLine = "\n"
//Draws a bitmap - for canvases that displays an image
void repaint(DBE graph) {
background(graph,
logicalMediumIndicatorColor)
// draw picture here
} // repaint
void RestoreModule(string strFullName)
{
bool bValidModule = true
bool bRestoreStatus
string message = restoreModule strFullName
if (!null message)
{
ack message
//halt
}
print "Module " strFullName strNewLine
} // RestoreModule()
void ProcessFolder(Folder fld)
{
Item itm
string FullModuleName
string ModuleName
Skip skpItems = createString() // used to put items alphabetically sorted
// [1] Get items in the folder
for itm in fld do
{
if (!isDeleted(itm)) put(skpItems, name(itm), itm)
}// for itm in fld do
// [2] process modules in the folder
for itm in skpItems do
{
if (type(itm) == "Formal")
{
FullModuleName = fullName(itm)
ModuleName = name(itm)
RestoreModule(ModuleName)
} // end if (type(itm) == "Formal")
} // end for itm in skpItems do
// [3] recurse sub-folders and projects
for itm in skpItems do
{
if (type(itm) == "Folder" or type(itm) == "Project")
ProcessFolder(folder(fullName(itm)))
} // end for itm in skpItems do
delete(skpItems)
} // ProcessFolder
string strDestinationFolderName = "/Test Area/ICAR/TOOLS Test Area/Test"// Doors directory
string strSourceFolderName = "U:\\DXL\\DMA" // Laptop
string strDialogTitle = "Restore Modules "
string strDefaultFolderPath = fullName current Folder
DB RestoreModuleBox = create(strDialogTitle)
imageCanvas = canvas(RestoreModuleBox, 400, 95, repaint) //puts the GE logo at top
DBE dbeLabel = label(RestoreModuleBox, "User shall be able to run a script on a directory to Restore module(s).")
DBE dbeDefaultFolderPath = field(RestoreModuleBox, "Folder Path:","", 80,true) //Setting to true grays out this field
// use this code from SmartDxl.com
//DBE dbeDestFolder = directoryName(RestoreModuleBox, "Destination Folder: ", strDestinationFolderName, false)
void Insert(DB RestoreModuleBox)
{
string strFilename
string strSourceDirectory = strSourceFolderName // hard coded for test
//string strDestDirectory = get dbeDestFolder
pragma runLim, 0 //disables the "Execution Timeout" dialog
if (strSourceDirectory != null)
{
bool bStatus = folder(strSourceFolderName)
print "bStatus " bStatus " " strSourceFolderName strNewLine
// bStatus is false
//ProcessFolder(current folder strDestinationFolderName)
//Unsuccessful at passing in the laptop directory to this function
// infoBox "Modules Restored from " strSourceDirectory " to " strDestDirectory
} // end if (strSourceDirectory != null)
if (showing RestoreModuleBox)
{
hide(RestoreModuleBox)
destroy(RestoreModuleBox) // free up resources now
} // end if (showing RestoreModuleBox)
} // Insert
apply(RestoreModuleBox, "OK", Insert)
set(dbeDefaultFolderPath, strDefaultFolderPath) // Update into the folder path area in dialog
show RestoreModuleBox // No text can appear after here as it will not be executed!!!!!!!!!
Gedinfo - Wed Apr 25 15:40:04 EDT 2012 |
Re: How to integrate Client folders with DOORS folders question Here's a snippette to find all the files in a particular Windows directory:
for NameFile in directory NameDir do
{ if (NameFile[0:0] == ".") // skip the "." and ".." file names. No other name may begin with '.'
continue
if (NameFile == NameDir) // Don't recall why, but skip a file with exact name as Directory
{ print ">>SearchDir, NameFile == NameDir '" NameFile "'\n"
continue
}
NameFull = NameDir "\\" NameFile
stat = create(NameFull)
// print "considering >" NameFull "<\n"
if (null stat) //
then something is wrong
else
{ if (directory(stat)) //
then this is a sub-folder
else this is a file
delete(stat)
}
}
|
Re: How to integrate Client folders with DOORS folders question I adapted your code, but now get a fail on restore. I have a directory of archived modules(*.dma), and for each module, restoreModule returns "Archive file does not exist". Yet, if I go through File > Restore > Module, the archived file is restored. |
Re: How to integrate Client folders with DOORS folders question Gedinfo - Thu Apr 26 12:39:39 EDT 2012 I think you messed up the file name, such as failing to insert a slash between the path and the basename.
-Louie |
Re: How to integrate Client folders with DOORS folders question
In my updated code, I get a message that the "New module name is invalid".
/*
Rev 1.000 - This script will perform an archive restore on modules residing in the DOORS Development server area.
Input - N/A
Output - N/A
*/
string strModuleName
string strNewLine = "\n"
//Draws a bitmap - for canvases that displays an image
void repaint(DBE graph) {
background(graph,
logicalMediumIndicatorColor)
// draw picture here
} // repaint
string strDestinationFolderName = "/Test Area/ICAR/TOOLS Test Area/Test"// Doors directory
string strSourceFolderName = "U:\\DXL\\DMA" // Laptop
string strDialogTitle = "Restore Modules "
string strDefaultFolderPath = fullName current Folder
DB RestoreDialog = create(strDialogTitle)
imageCanvas = canvas(RestoreDialog, 400, 95, repaint) //puts the GE logo at top
DBE dbeLabel = label(RestoreDialog, "User shall be able to run a script on a directory to Restore module(s).")
DBE dbeDefaultFolderPath = field(RestoreDialog, "Folder Path:","", 80,true) //Setting to true grays out this field
/******************************************************************************
fReplaceUnderscore
Replaces underscores in a buffer with spaces
******************************************************************************/
void fReplaceUnderscore(Buffer in_buf)
{ // Replace all occurances of underscore to space in the Buffer
char in_cFrom = '_'
char in_cTo = ' '
if (null in_buf) return
int i
for (i=0; i<length(in_buf); i++)
{
if (in_buf[i] == in_cFrom) set(in_buf, i, in_cTo)
}
//print "in_buf[i] = " in_buf[i] strNewLine
} // fReplaceNewLine()
void RestoreTheModule(string strSource, string strDest)
{
string message = restoreModule(strSource, strDest)
/* if (!null message)
{
ack message
//halt
}*/
print "Module " strDest " " message strNewLine
} // RestoreTheModule()
void PrintFilesInDirectory()
{
string file
int nLength
int nStart
string strSource
string strDest
string strNoExtension
string strDMA = ".dma"
for file in directory strSourceFolderName do
{
Buffer TextBuf = create
if (file[0:0] == ".") // skip the "." and ".." file names. No other name may begin with '.'
continue
if (file == strSourceFolderName) // Don't recall why, but skip a file with exact name as Directory
{
print ">>SearchDir, file == strSourceFolderName '" file "'\n"
continue
} // end if (file == strSourceFolderName)
TextBuf = file
nLength = length(file)
nStart = nLength-4
print "Start " nStart " length" nLength strNewLine
if (file[nStart:nLength] == strDMA) //Proceed if this is a *.dma
{
strSource = strSourceFolderName "\\" file
fReplaceUnderscore(TextBuf)
file = stringOf(TextBuf)
nStart -= 1
strNoExtension = file[0:nStart]
strDest = strDestinationFolderName "/" strNoExtension
RestoreTheModule(strSource, strDest)
} // end if (bDMAExtension)
delete(TextBuf)
} // end for file in directory strSourceFolderName do
} //PrintFilesInDirectory()
void Insert(DB RestoreDialog)
{
string strFilename
// trace according to a folder of configuration files
//string strSourceDirectory = get dbeSourceFolder
string strSourceDirectory = strSourceFolderName
string strDestDirectory = strDestinationFolderName
pragma runLim, 0 //disables the "Execution Timeout" dialog
print description (current Folder) strNewLine
PrintFilesInDirectory
infoBox "Modules Restored from " strSourceDirectory " to " strDestDirectory
if (showing RestoreDialog)
{
hide(RestoreDialog)
destroy(RestoreDialog) // free up resources now
} // end if (showing RestoreTheModuleBox)
} // Insert
apply(RestoreDialog, "OK", Insert)
set(dbeDefaultFolderPath, strDefaultFolderPath) // Update into the folder path area in dialog
show RestoreDialog // No text can appear after here as it will not be executed!!!!!!!!!
|
Re: How to integrate Client folders with DOORS folders question Gedinfo - Thu Apr 26 15:31:39 EDT 2012
In my updated code, I get a message that the "New module name is invalid".
/*
Rev 1.000 - This script will perform an archive restore on modules residing in the DOORS Development server area.
Input - N/A
Output - N/A
*/
string strModuleName
string strNewLine = "\n"
//Draws a bitmap - for canvases that displays an image
void repaint(DBE graph) {
background(graph,
logicalMediumIndicatorColor)
// draw picture here
} // repaint
string strDestinationFolderName = "/Test Area/ICAR/TOOLS Test Area/Test"// Doors directory
string strSourceFolderName = "U:\\DXL\\DMA" // Laptop
string strDialogTitle = "Restore Modules "
string strDefaultFolderPath = fullName current Folder
DB RestoreDialog = create(strDialogTitle)
imageCanvas = canvas(RestoreDialog, 400, 95, repaint) //puts the GE logo at top
DBE dbeLabel = label(RestoreDialog, "User shall be able to run a script on a directory to Restore module(s).")
DBE dbeDefaultFolderPath = field(RestoreDialog, "Folder Path:","", 80,true) //Setting to true grays out this field
/******************************************************************************
fReplaceUnderscore
Replaces underscores in a buffer with spaces
******************************************************************************/
void fReplaceUnderscore(Buffer in_buf)
{ // Replace all occurances of underscore to space in the Buffer
char in_cFrom = '_'
char in_cTo = ' '
if (null in_buf) return
int i
for (i=0; i<length(in_buf); i++)
{
if (in_buf[i] == in_cFrom) set(in_buf, i, in_cTo)
}
//print "in_buf[i] = " in_buf[i] strNewLine
} // fReplaceNewLine()
void RestoreTheModule(string strSource, string strDest)
{
string message = restoreModule(strSource, strDest)
/* if (!null message)
{
ack message
//halt
}*/
print "Module " strDest " " message strNewLine
} // RestoreTheModule()
void PrintFilesInDirectory()
{
string file
int nLength
int nStart
string strSource
string strDest
string strNoExtension
string strDMA = ".dma"
for file in directory strSourceFolderName do
{
Buffer TextBuf = create
if (file[0:0] == ".") // skip the "." and ".." file names. No other name may begin with '.'
continue
if (file == strSourceFolderName) // Don't recall why, but skip a file with exact name as Directory
{
print ">>SearchDir, file == strSourceFolderName '" file "'\n"
continue
} // end if (file == strSourceFolderName)
TextBuf = file
nLength = length(file)
nStart = nLength-4
print "Start " nStart " length" nLength strNewLine
if (file[nStart:nLength] == strDMA) //Proceed if this is a *.dma
{
strSource = strSourceFolderName "\\" file
fReplaceUnderscore(TextBuf)
file = stringOf(TextBuf)
nStart -= 1
strNoExtension = file[0:nStart]
strDest = strDestinationFolderName "/" strNoExtension
RestoreTheModule(strSource, strDest)
} // end if (bDMAExtension)
delete(TextBuf)
} // end for file in directory strSourceFolderName do
} //PrintFilesInDirectory()
void Insert(DB RestoreDialog)
{
string strFilename
// trace according to a folder of configuration files
//string strSourceDirectory = get dbeSourceFolder
string strSourceDirectory = strSourceFolderName
string strDestDirectory = strDestinationFolderName
pragma runLim, 0 //disables the "Execution Timeout" dialog
print description (current Folder) strNewLine
PrintFilesInDirectory
infoBox "Modules Restored from " strSourceDirectory " to " strDestDirectory
if (showing RestoreDialog)
{
hide(RestoreDialog)
destroy(RestoreDialog) // free up resources now
} // end if (showing RestoreTheModuleBox)
} // Insert
apply(RestoreDialog, "OK", Insert)
set(dbeDefaultFolderPath, strDefaultFolderPath) // Update into the folder path area in dialog
show RestoreDialog // No text can appear after here as it will not be executed!!!!!!!!!
On other news...
-Louie |